<%--
    Document   : listsearv
    Created on : Nov 27, 2011, 5:20:26 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.ThamSoHT,Models.ThamSoHT_Model, Models.DatBan_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'datemsg', 'to', 'timehistory', 'phonenumber', 'reservlist', 'rightmsg', 'tablename', 'areaname', 'customer', 'delete', 'from', 'hours', 'notice', 'numberofcustomer' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.


            String areaname = mdsts[0].getTenTS();
            String customer = mdsts[1].getTenTS();
            String datemsg = mdsts[2].getTenTS();
            String delete = mdsts[3].getTenTS();
            String from = mdsts[4].getTenTS();
            String hours = mdsts[5].getTenTS();
            String notice = mdsts[6].getTenTS();
            String numberofcustomer = mdsts[7].getTenTS();
            String phonenumber = mdsts[8].getTenTS();
            String reservlist = mdsts[9].getTenTS();
            String rightmsg = mdsts[10].getTenTS();
            String tablename = mdsts[11].getTenTS();
            String timehistory = mdsts[12].getTenTS();
            String to = mdsts[13].getTenTS();

            String msgright = notice + "/" + rightmsg;
            String msgdate = notice + "/" + datemsg;

            Vector vDSDB = (Vector) request.getAttribute("DSDB");


            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vDSDB.size();
            if (vsize % 4 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 4;
            } else {
                numpage = vsize / 4 + 1;
            }

            String xx = (String) request.getAttribute("itemdb");
            String tenkv = (String) request.getAttribute("tenkv");
            String tenban = (String) request.getAttribute("tenban");
            String kh = (String) request.getAttribute("kh");
            String sodt = (String) request.getAttribute("sodt");
            String sokhach = (String) request.getAttribute("sokhach");
            String tungay = (String) request.getAttribute("tungay");
            String tugio = (String) request.getAttribute("tugio");
            String denngay = (String) request.getAttribute("denngay");
            String dengio = (String) request.getAttribute("dengio");

            int item = Integer.parseInt(xx);
            int total = 0;
%>
<script type="text/javascript">
    $(function(){
        
        $('#datepicker2').datepicker($.datepicker.regional['vi']);
        $( "#datepicker2" ).datepicker( "option", "dateFormat","dd/mm/yy");
        $('#datepicker3').datepicker($.datepicker.regional['vi']);
        $( "#datepicker3" ).datepicker( "option", "dateFormat","dd/mm/yy");
    });
</script>
<div class="title">
    <%=reservlist%>
</div>
<div class="content">
    <form name="dsdb" action="">
        <table>
            <thead>
                <tr>
                    <th style="width: 7%;" class="STT">
                        <input type="checkbox" onclick="CheckAllDB()">
                    </th>
                    <th style="width: 21%;">
                        <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchNgayGioDB(this.className, this.name, this.lang)">
                            <div style="float:left"><%=timehistory%></div>
                            <div style=" margin-right: 75px;" id="sortkv1" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 14%;">
                        <a href="#" id="titledskv2" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" onclick="SortSearchKVDB( this.className, this.name, this.lang)">
                            <div style="float:left"><%=areaname%></div>
                            <div style=" margin-right: 25px;" id="sortkv2" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 11%;">
                        <a href="#" id="titledskv3" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchTenBanDB( this.className, this.name, this.lang)">
                            <div style="float:left"><%=tablename%></div>
                            <div style=" margin-right: 10px;" id="sortkv3" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 15%;">
                        <a href="#" id="titledskv4" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchKHDB( this.className, this.name, this.lang)">
                            <div style="float:left"><%=customer%></div>
                            <div style=" margin-right: 30px;" id="sortkv4" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 14%;">
                        <a href="#" id="titledskv5" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchDTDB( this.className, this.name, this.lang)">
                            <div style="float:left"><%=phonenumber%></div>
                            <div style=" margin-right: 15px;" id="sortkv5" class="down1"></div>
                        </a>
                    </th>
                    <th style="">
                        <a href="#" id="titledskv6" class="down" lang="<%=msgright%>"  name="1" onclick="SortSearchSoKhachDB( this.className, this.name, this.lang)">
                            <div><%=numberofcustomer%></div>
                            <div >
                                <div id="sortkv6" class="down2"></div>
                                <div id="sortkv6" class="up2" style="display:none;"></div>
                            </div>
                        </a>
                    </th>
                    <th></th>
                </tr>
                <tr id="searchDB">
                    <td><img onclick="SearchDB(this.alt, this.lang, this.id)" id="<%=msgdate%>" style=" margin-top: 10px; margin-bottom: -20px;" class="searchKV" alt="1" lang="<%=msgright%>" src="images/search1.png"></td>
                    <td>
                        <div style=" width: 35px; float: left;"><%=from%></div>
                        <input type="textbox" maxlength="10" value="<%=tungay%>" class="text tungay" style=" width: 80px; margin-right: 5px; margin-bottom: 5px;" id="datepicker2">
                        <input type="textbox" class="text tugio" value="<%=tugio%>" style=" width: 30px;  margin-right: 2px;  margin-bottom: 5px;" maxlength="2" onkeypress="return keypress(event)" value="0"><%=hours%>
                        <br />
                        <div style=" width: 35px; float: left;"><%=to%></div>
                        <input type="textbox" maxlength="10" value="<%=denngay%>" class="text denngay" style=" width: 80px; margin-right: 5px; margin-bottom: 5px; " id="datepicker3">
                        <input type="textbox" class="text dengio" value="<%=dengio%>" style=" width: 30px;  margin-right: 2px; margin-bottom: 5px;" maxlength="2" onkeypress="return keypress(event)" value="0"><%=hours%>
                    </td>
                    <td>
                        <input type="textbox" style=" width: 100px;" value="<%=tenkv%>" class="tenkv text">
                    </td>
                    <td>
                        <input type="textbox" style=" width: 55px;" value="<%=tenban%>" class="tenban text" onkeypress="return keypress(event)">
                    </td>
                    <td>
                        <input type="textbox" style=" width: 100px;" value="<%=kh%>" class="kh text">
                    </td>
                    <td><input type="textbox" style=" width: 85px;" value="<%=sodt%>" class="sodt text" onkeypress="return keypress(event)"></td>
                    <td>
                        <input type="textbox" style=" width: 85px;" value="<%=sokhach%>" class="sokhach text" onkeypress="return keypress(event)">
                    </td>
                    <td></td>
                </tr>
            </thead>
            <tbody>
                <%
                            for (int i = (item - 1) * 4; i < (item - 1) * 4 + 4 && i < vsize; i++) {
                                Beans.DatBan db = (Beans.DatBan) vDSDB.elementAt(i);
                                total = total + 1;
                %>
                <tr>
                    <td class="STT"><input type="checkbox" value="<%= db.getMaDB() %>" class="optionDB" name="optionDB"></td>
                    <td ><%= db.getNgay()%>  -  <%= db.getGio()%>   <%=hours%></td>
                    <td ><%=DatBan_Model.LayTenKV(db.getMaBan(), langid)%></td>
                    <td style=" padding-left: 15px;" ><%=DatBan_Model.LayTenBan(db.getMaBan())%></td>
                    <td><%=db.getKhachHang()%></td>
                    <td><%=db.getSoDT()%></td>
                    <td style=" padding-left: 15px;"><%=db.getSoKhach()%></td>
                    <td><a href="#" name="<%=msgright%>" id="<%=db.getMaDB()%>" lang="<%=db.getMaBan()%>" onclick="DetailDB(this.name, this.id, this.lang)"><img style="width: 17px; margin-top: 2px;" alt="" src="images/edit.png"></a></td>
                </tr>
                <%  }%>
                <input type="hidden" name="total" value="<%=total%>">
            </tbody>
        </table>
        <div style="float:left;">
                <input type="button" style="margin-left: 0; margin-top: 5px; margin-bottom: 5px;" class="button" value ="<%=delete%>" lang="<%=msgright%>" id="1" onclick="DeleteDB( this.id, this.lang)">
        </div>
        <div class="pagination" style=" margin-top: 20px;">
            <%
                        int trang = 1;
                        if (item > 1) {
                            trang = item - 1;
                        }
            %>
            <%
                            if (vsize > 4) {%>
                            <a href="#" class="prev"  name="<%= trang%>" lang="<%=msgright%>" id="<%=msgdate%>" onclick="searchDB( this.name, this.lang, this.id)">«</a>
            <%      for (int c = 1; c <= numpage; c++) {
                                        if (c != item) {
            %>              <a href="#"  name="<%= c%>" lang="<%=msgright%>" id="<%=msgdate%>" onclick="searchDB( this.name, this.lang, this.id)" ><%= c%></a>
            <%          } else {%><a class="current"> <%= c%></a> <% }
                                    }
            %>
            <%      if (item + 1 <= numpage) {
                                        trang = item + 1;
                                    } else {
                                        trang = item;
                                    }
            %>
            <a href="#" class="next"  name="<%= trang%>" lang="<%=msgright%>" id="<%=msgdate%>" onclick="searchDB( this.name, this.lang, this.id)">»</a>
            <%  }
            %>
        </div>
    </form>
</div>
